package com.example.constantAndMethod;

/**
 * @Author 郅占伟
 * @ClassName Color
 * @Description TODO
 * @Date 2024年05月13日
 * @Version: 1.0
 */
public enum Color {
    RED("红色", 1),
    ORANGE("橙色", 2),
    YELLOW("黄色", 3),
    GREEN("绿色", 4),
    CYAN("青色", 5),
    BLUE("蓝色", 6),
    PURPLE("紫色", 7);

    private String colorName;
    private int colorCode;

    private Color(String colorName, int colorCode) {
        this.colorName = colorName;
        this.colorCode = colorCode;
    }

    // 普通方法
    public static String getColorName(int colorCode) {
        for (Color c : Color.values()) {
            if (c.getColorCode() == colorCode) {
                return c.colorName;
            }
        }
        return null;
    }

    public String getColorName() {
        return colorName;
    }

    public void setColorName(String colorName) {
        this.colorName = colorName;
    }

    public int getColorCode() {
        return colorCode;
    }

    public void setColorCode(int colorCode) {
        this.colorCode = colorCode;
    }
}
